<?php
	$this->headScript()->appendFile(HTTP_HOST.'/js/jQuery/photos.js');
	$this->headScript()->appendFile(HTTP_HOST.'/js/site-manager/objects.js');
	$this->headScript()->appendFile(HTTP_HOST.'/js/jQuery/jquery.cleditor.min.js');
	$this->headLink()->appendStylesheet(HTTP_HOST.'/css/jquery/cleditor/jquery.cleditor.css');
	$this->headScript()->captureStart();
?>
	$(document).ready(function(){
		$('textarea[name="FullDescription"]').cleditor();
	});
<?php
	 $this->headScript()->captureEnd();
?>
<?php if(sizeOf($this->error)>0){?>
	<div id="_form_errors">
		<h1><?=$this->object['ID'] == 0 ? $this->translate('Ошибка при добавлении') : $this->translate('Ошибка при редактировании')?></h1>
		<ul>
			<?php 
				foreach ($this->error as $k=>$v){				
					echo "<li>",$v,"</li>";				
				}
			?>
		</ul>
	</div>
<?php } ?>
<div id="add_new_object">
<form action="<?=HTTP_HOST?>/site-manager/object/save" method="post"  enctype='multipart/form-data'>
<input type="hidden" name="page" value="<?=$this->pageNumber?>" />
<input type="hidden" name="ID" value="<?=$this->object['ID']?>" />
<?php $i = 1;?>
<table id="add_cat_table">
	<tr class="head">
		<td colspan="2"><?=$this->object['ID'] == 0 ? $this->translate('Добавить объект') : $this->translate('Редактировать объект')?></td>
	</tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Выберите страну'); ?></td><td><?=$this->formSelect('CountryID', $this->country, array('onchange' => 'reloadRegions(this.value);', 'onload' => 'reloadRegions(this.value);'), $this->countries);?></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Выберите регион'); ?></td><td><?=$this->formSelect('RegionID', $this->region, array('onchange' => 'reloadCities(this.value);'), $this->regions);?></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Выберите город'); ?></td><td><?=$this->formSelect('CityID', $this->city, array('onchange' => 'reloadLocations(this.value);'), $this->cities);?></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Выберите район'); ?></td><td><?=$this->formSelect('LocationID', $this->location, array(), $this->locations);?></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Название объекта'); ?></td><td><input type="text" name="Name" value='<?=htmlentities(stripslashes($this->object['Name']), ENT_QUOTES, 'utf-8')?>' id="title"/></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Короткое описание'); ?></td><td><textarea name="ShortDescription" id="ShortDescription"><?=$this->object['ShortDescription']?></textarea></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Полное описание'); ?></td><td><textarea name="FullDescription" style="height: 270px;"><?=stripslashes($this->object['FullDescription'])?></textarea></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Выберите картинки'); ?></td><td>
		<div id="object_images">
			<?php if(sizeOf($this->images)>0):?>
				<?php foreach($this->images as $v): ?>
					<div class="preview_img_div">
						<?php if(!$v['Main']):?><img src="<?=HTTP_HOST;?>/images/controll/close.png" class="delete_object_image" id="<?=$v['ID'];?>" rel="<?=$v['OriginalName'];?>" title="Удалить фотографию"/><?php endif;?>
						<img src="<?=HTTP_HOST;?>/images/controll/<?=($v['Main'])?'green-':'red-';?>flag.png" class="main_page_image" id="<?=$v['ID'];?>" rel="<?=$v['OriginalName'];?>" title="<?=($v['Main'])?'Фотография на главной':'Назначить фотографию на главную';?>"/>
						<img src="<?=Obj_Image::thumbnail($v['ID'], 105, 80);?>" class="object_image"/->
						
					</div>
				<?php endforeach; ?>
			<?php endif; ?>
		</div>
		<table id="add_photo_table">
			<tbody id="files_table">
				<tr id='objectfield_1'>
					<td>
						<input type="file" name="objectFile[]"/>
					</td>
					<td>
						<input type="radio" name="main" value="objectfile_1">
					</td>
				</tr>
			</tbody>
		</table>
		<div style="position: relative; float: right; width: 100%"><div id="new_file_div"><?=$this->translate('Добавить файл'); ?></div></div>
	</td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Арибут'); ?></td>
		<td>
			<p><input type="radio" name="Attribute" value="1" id="oa1"<?=$this->object['Attribute'] == OBJECT_SALE ? ' checked="checked"' : ''?> /> <label for="oa1"><?=$this->translate('Продажа'); ?></label></p>
			<p><input type="radio" name="Attribute" value="2" id="oa2"<?=$this->object['Attribute'] == OBJECT_RENT ? ' checked="checked"' : ''?>/> <label for="oa2"><?=$this->translate('Аренда'); ?></label></p>
			<p><input type="radio" name="Attribute" value="3" id="oa3"<?=$this->object['Attribute'] == OBJECT_INVESTMENT_PROJECT ? ' checked="checked"' : ''?>/> <label for="oa3"><?=$this->translate('Инвестпроект'); ?></label></p>
		</td>
	</tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Адрес'); ?></td><td><textarea name="Adress"><?=$this->object['Adress']?></textarea></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Порядок сортировки:'); ?></td><td><input type="text" name="Sort" value="<?=$this->object['Sort']?>" /></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Расстояние до моря (м)'); ?></td><td><input type="text" name="DistanceToSea" value="<?=$this->object['DistanceToSea']?>" /></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Расстояние до аэропорта (км)'); ?></td><td><input type="text" name="DistanceToAirport" value="<?=$this->object['DistanceToAirport']?>" /></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Тип объекта'); ?></td><td><?=$this->formSelect('ObjectTypeId', $this->object['ObjectTypeId'], array(), $this->ObjectTypeId);?></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Год постройки'); ?></td><td><input type="text" name="YearOfConstruction" value="<?=$this->object['DistanceToAirport']?>" /></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Количество этажей объекта'); ?></td><td><input type="text" name="Floor" value="<?=$this->object['Floor']?>" /></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Площадь от м<sup>2</sup>'); ?></td><td><input type="text" name="Area" value="<?=$this->object['Area']?>" /></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Площадь до м<sup>2</sup>'); ?></td><td><input type="text" name="AreaTo" value="<?=$this->object['AreaTo']?>" /></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Количество спален'); ?></td><td><input type="text" name="NumberOfBedrooms" value="<?=$this->object['NumberOfBedrooms']?>" /></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Количество ванных комнат'); ?></td><td><input type="text" name="NumberOfBathrooms" value="<?=$this->object['NumberOfBathrooms']?>" /></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Бассейн'); ?></td><td><input type="checkbox" name="SwimmingPool" <?=$this->object['SwimmingPool'] == 1 ? ' checked="checked"' : ''?>/></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Паркинг'); ?></td><td><input type="checkbox" name="Parking" <?=$this->object['Parking'] == 1 ? ' checked="checked"' : ''?>/></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Охрана'); ?></td><td><input type="checkbox" name="Security" <?=$this->object['Security'] == 1 ? ' checked="checked"' : ''?>/></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Лифт'); ?></td><td><input type="checkbox" name="Elevator" <?=$this->object['Elevator'] == 1 ? ' checked="checked"' : ''?>/></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Детский бассейн'); ?></td><td><input type="checkbox" name="ChildrensPool" <?=$this->object['ChildrensPool'] == 1 ? ' checked="checked"' : ''?>/></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Детская площадка'); ?></td><td><input type="checkbox" name="Playground" <?=$this->object['Playground'] == 1 ? ' checked="checked"' : ''?>/></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Отопление'); ?></td><td><input type="checkbox" name="Heating" <?=$this->object['Heating'] == 1 ? ' checked="checked"' : ''?>/></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Горячая вода'); ?></td><td><input type="checkbox" name="HotWater" <?=$this->object['HotWater'] == 1 ? ' checked="checked"' : ''?>/></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Валюта'); ?></td><td><?=$this->formSelect('Сurrency', $this->Сurrency, array(), $this->Currencies);?></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Цена от'); ?></td><td><input type="text" name="Price" value="<?=$this->object['Price']?>" /></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Цена до'); ?></td><td><input type="text" name="PriceTo" value="<?=$this->object['PriceTo']?>" /></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Активный'); ?></td><td><input type="checkbox" name="Active"<?=$this->object['Active'] == 1 ? ' checked="checked"' : ''?>/></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('SЕО Title'); ?></td><td><textarea name="SeoTitle"><?=$this->object['SeoTitle']?></textarea></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('SEO Keywords'); ?></td><td><textarea name="SeoKeywords"><?=$this->object['SeoKeywords']?></textarea></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('SEO Description'); ?></td><td><textarea name="SeoDescription"><?=$this->object['SeoDescription']?></textarea></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('Агент'); ?></td><td><select name="Agent"><option value="0">No agent</option></select></td></tr>
	<tr <?=(is_int($i/2))?"class='dark_tr'":"class='white_tr'"; $i++; ?>><td class="field_name"><?=$this->translate('На главную страницу'); ?></td><td><input type="checkbox" name="FronPage"<?=$this->object['FronPage'] == 1 ? ' checked="checked"' : ''?>/></td></tr>
	<tr class='add_teble_footer'><td colspan="2"><input type="submit" value="<?=$this->translate('Сохранить')?>"/></td></tr>
</table>
</form>

<div id="small_shadow"></div>

</div>
